package com.typy.www.tpay.ui.itemview;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.typy.www.tpay.R;
import com.typy.www.tpay.bean.vm.ActivicationVm;
import com.typy.www.tpay.constance.MessageEvent;
import com.typy.www.tpay.ui.acitivity.WebActivity;
import com.typy.www.tpay.util.MessageAction;
import com.typy.www.tpay.util.UpdataUiUtil;
import com.zhy.android.percent.support.PercentLinearLayout;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 13799 on 2018/7/28.
 */

public class BuyWeiWanItem {
    View mView;
    ViewHolder holder;
    private Context mContext;

    public BuyWeiWanItem(Context context) {
        mContext = context;
        mView = LayoutInflater.from(context).inflate(R.layout.item_buyweiwan, null);
        holder = new ViewHolder(mView);
    }

    public View getView() {
        return mView;
    }

    public void bind(final ActivicationVm vm, final int position) {

        UpdataUiUtil.getDefaul().setText(vm.getFdAmount(), holder.tvYewuleixing)
                .setText(vm.getFdCreateTime(), holder.tvShue);
        holder.tvQiandao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                EventBus.getDefault().post(new MessageEvent(MessageAction.BUYCANCELORDER,vm.getFdOrderId()));
            }
        });
    }


    static class ViewHolder {
        @BindView(R.id.tv_yewuleixing)
        TextView tvYewuleixing;
        @BindView(R.id.tv_shue)
        TextView tvShue;
        @BindView(R.id.tv_shijian)
        TextView tvShijian;
        @BindView(R.id.tv_qiandao)
        TextView tvQiandao;
        @BindView(R.id.ll_root)
        PercentLinearLayout llRoot;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
